package cn.jhc.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;




import cn.jhc.dao.Imp.GetAllUsers;
import uuntil.Constants;

/**
 * Servlet implementation class CheckAllUserNameAndPassword
 */
@WebServlet("/checklogin.do")
public class CheckAllUserNameAndPassword extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public CheckAllUserNameAndPassword() {
        super();
        // TODO Auto-generated constructor stub
    }

	boolean b=true;
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String username=request.getParameter("username");
		String password=request.getParameter("password");
		DataSource dataSource = (DataSource)request.getServletContext().getAttribute(Constants.H2_DATASOURCE);
		try {
			b=GetAllUsers.getAllUserNameAndPass(dataSource,username, password);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		response.setContentType("appliction/json;charset=UTF-8");
		PrintWriter out=response.getWriter();
		out.print(b);

		
	}

}
